package com.demo.shiroDemo04.web;

import com.demo.shiroDemo04.model.User;
import com.jfinal.core.Controller;

public class UserController extends Controller {
	
	// url=/user/list
//	@RequiresRoles("admin")
	public void list() {
		renderJson(User.USERS);
	}

	// url=/user?id=
//	@RequiresPermissions("user:query:1")
	public void one() {
		Integer id = getParaToInt("id");
		User user = User.USER_MAP.get(id);
		renderJson(user);
	}

	// url=/user/add?username=&password=
//	@RequiresPermissions("user:add")
	public void add() {
		User user = User.addUser(getPara("username"), getPara("password"));
		renderJson(user);
	}
	
}
